<template>
    <div class="nav-container">
        <FloatingBox :max-height="floatingHeight">
            <div class="info">
                <span class="name">{{ currentPol.name }}</span>
                <span class="addr">{{ currentPol.address }}</span>
                <span class="type">{{ currentPol.type }}</span>
            </div>
        </FloatingBox>
        <div class="footer-nav">
            <div class="item">
                <i class="iconfont icon-search"></i>
                周边
            </div>
            <div class="item">
                <i class="iconfont icon-star1"></i>
                收藏
            </div>
            <div class="item">
                <i class="iconfont icon-share-o"></i>
                分享
            </div>
            <div class="item">
                <i class="iconfont icon-hotel"></i>
                订酒店
            </div>
            <div>
                <van-button size="small" round @click.stop="handleNavigation">导航</van-button>
                <van-button size="small" round type="primary" @click.stop="handleRoute">路线</van-button>
            </div>
        </div>
    </div>
</template>

<script setup lang='ts'>
import { inject, ref } from 'vue'
import { useRoute ,useRouter } from 'vue-router';
import FloatingBox from '@/components/FloatingBox.vue';
import router from '@/router';
import { mapEventBusKey } from '@/iDent';

const mapRef = inject(mapEventBusKey);
const { getPolDetailById } = mapRef.value;
const floatingHeight = window.innerHeight * 0.67;
const $route = useRoute();
const $router = useRouter();

const currentPol = ref({});

getPolDetailById($route.params.id, (status, res) => {
    if(status === 'complete') {
        currentPol.value = res.poiList.pois[0];
    }
})

const handleNavigation = () => {}
const handleRoute = () => {
    const { name,  location: { lng, lat }, id} = currentPol.value;
    $router.push({name: 'route', params: {
        name,
        lng,
        lat,
        id
    }});
}


</script>
<style scoped lang="scss">
.nav-container {
    pointer-events: none;
    background: transparent;

    .footer-nav {
        position: absolute;
        bottom: 0px;
        left: 0px;
        width: 100%;
        display: flex;
        align-items: center;
        color: #333;
        font-size: 18px;
        pointer-events: auto;
        box-shadow: 0 1px 2px 1px #999;
        background-color: #fff;
        padding: 10px 10px 20px;
        justify-content: space-around;
        .item {
            display: flex;
            flex-direction: column;
            align-items: center;
            i {
                font-size: 26px;
                &.icon-hotel {
                    font-size: 20px;
                }
            }
        }
        button {
            padding: 0px 28px;
            margin-right: 20px;
        }
    }
}
.info {
    font-size: 20px;
    color: #333;
    display: flex;
    flex-direction: column;
    padding: 34px 30px 20px;
    border-bottom: 1px solid #f1f1f1;
    .name {
        font-size: 36px;
        font-weight: bold;
    }
}
</style>